<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>核销报单管理 - 销售业绩管理系统</title>
<style type="text/css">
<!--
.STYLE1 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 12px;
}
.STYLE6 {font-size: 12px; }
.STYLE7 {font-size: 12px; background-color: #f5f5f5;margin:0;}
body { 
margin:0;
}
-->
</style>
</head>

<body margin=0>

<table width="100%" bgcolor="#FFFFFF"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="28" class="STYLE7">核销报单管理 &gt;核销报单提交</td>
  </tr>
  <tr>
    <td valign="top"><table width="50%" align="center" >
      <tr>
        <td height="25" colspan="2" bordercolor="#000000" bgcolor="#1C94C4"><div align="center" class="STYLE1">核销报单创建</div></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;所属业务员名称：</div>
        </div></td>
		  <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
		  <input id="ywyid" type="hidden"></input>
          <input id="ywyname" name="textfield3" type="text"  disabled="disabled" size="10"/>
          </label>
          <label>
          <a href="#" onclick="showUsers()"><input type="submit" name="Submit2" value="选择业务员名称" /></a>
          </label>
		  </span></td>
	  <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;所属美容院名称：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
          <select id="mrylist" name="select" onchange="selectShop()">
          </select>
          </label>
        </span></td>
      </tr>
        <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;销售套数：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
        <input id="lastnum" type="hidden"></input>
          <input id="salesnum" name="textfield4" type="text" size="10" onkeyup="changejf()" />
        </span></td>
      </tr>
	  	  <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;核销报单积分：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
          <input id="hxbdjf" name="textfield4" type="text" size="10" />
           <input id="hxbdjf1" name="textfield4" type="hidden" size="10" />
          <input id="preten" type="checkbox" style="margin-left:20px;" onchange="changejf()">销售前10套不计入积分</input>
        </span></td>
      </tr>
	   <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;累计核销积分：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
       	 <input id="lastljhxjf" type="hidden" />
          <input id="ljhxjf" name="textfield4" type="text" />
        </span></td>
      </tr>
	  <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;地址：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
          <input id="address" type="text" name="textfield" />
          </label>
        </span></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;所属城市：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><select id="cities" name="select"></select></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;联系人（法人）：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><input id="lxr" name="textfield22" type="text" /></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;联系电话：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><input id="telphone" name="textfield222" /></td>
      </tr>
      <tr>
        <td height="25" colspan="2" bgcolor="#1C94C4"><div align="center" class="STYLE6">
            <form action="" method="post" name="form1" id="form1">
              <label>
              <input type="button" name="Submit" value="创 建"  onclick="winalert()"/>
              </label>
            </form>
        </div></td>
      </tr>
    </table></td>
  </tr>
</table>
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
	<script language="javascript">
	$.get("../user/fetchcities",{},function(json){
		var opStr = "";
		for(var i = 0,l = json.length ; i < l ; i++)
		{
			opStr += "<option>" + json[i].CityName + "</option>";
		}
		$("#cities").empty().append(opStr);
	});
	
	function winalert(){
		$.post("../verification/add",{
			ywyid:$("#ywyid").val(),
			ywy:$("#ywyname").val(),
			mryname:$("#mrylist").find("option:selected").text(),
			mryid:$("#mrylist").val(),
			ljhxjf:$("#ljhxjf").val(),
			hxbdjf:$("#hxbdjf1").val(),
			address:$("#address").val(),
			cities:$("#cities").val(),
			telphone:$("#telphone").val(),
			salesnum:$("#salesnum").val(),
			lxr:$("#lxr").val()
		},function(json){
			alert("添加成功！");
		});
	}
		function showUsers(){
			var value = showModalDialog('VerificationUsers.html','选择业务员','dialogWidth:500px;dialogHeight:600px; dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes'); 
			var ywy = value.split(",");
			$("#ywyid").prop("value",ywy[0]);
			$("#ywyname").prop("value",ywy[1]);
			
			$.get("../shop/ywyallshop",{id:ywy[0]},function(json){
				var opStr = "<option value='0'>请选择</option>";
				for(var i = 0,l = json.length ; i < l ; i++)
				{
					opStr += "<option value='" + json[i].ID + "'>" + json[i].BeautyShopName + "</option>";
				}
				$("#mrylist").empty().append(opStr);
			});
		}
		function changejf(){
			$("#hxbdjf").prop("value",0);
			$("#hxbdjf1").prop("value",0);
			var num = 0,hxbdjf = 0,hxbdjf1 = 0,ljhxjf = 0,lastljhxjf = 0,lastnum = 0;
			if($("#salesnum").val() != null && $("#salesnum").val() != "")
				num = parseInt($("#salesnum").val());
			if($("#hxbdjf").val() != null && $("#hxbdjf").val() != "")
				xbdjf = parseInt($("#hxbdjf").val());
			
			if($("#ljhxjf").val() != null && $("#ljhxjf").val() != "")
				ljhxjf = parseInt($("#ljhxjf").val());
			if($("#lastljhxjf").val() != null && $("#lastljhxjf").val() != "")
				lastljhxjf = parseInt($("#lastljhxjf").val());
			if($("#lastnum").val() != null && $("#lastnum").val() != "")
				lastnum = parseInt($("#lastnum").val());
			
			if($("#preten").prop("checked")){
				if(lastnum < 10){
					if((num + lastnum) <= 10)
						num = 0;
					else{
						num = num - 10 + parseInt(lastnum)
					}
				}
				$("#hxbdjf1").prop("value",num * 500);
			}else{
				$("#hxbdjf1").prop("value",(num + lastnum) * 500);
			}
			$("#hxbdjf").prop("value",num * 500);
			$("#ljhxjf").prop("value",(parseInt(num * 500) + parseInt(lastljhxjf)));
		}
		function selectShop(){
			var id = $("#mrylist").val();
			$.get("../shop/shopjf",{id:id},function(json){
				if(json != null){
					$("#hxbdjf").prop("value",0);
					$("#hxbdjf1").prop("value",0);
					$("#ljhxjf").prop("value",json.InitIntegral);
					$("#lastljhxjf").prop("value",json.InitIntegral);
					$("#lastnum").prop("value",json.lastsalesnum);
					$("#address").prop("value",json.BeautyShopAddress);
					$("#lxr").prop("value",json.RelationMan);
					$("#telphone").prop("value",json.Telephone);
				}else
					{
						$("#hxbdjf").prop("value",0);
						$("#hxbdjf1").prop("value",0);
						$("#ljhxjf").prop("value",0);
						$("#lastljhxjf").prop("value",0);
						$("#lastnum").prop("value",0);
						$("#address").prop("value","");
						$("#lxr").prop("value","");
						$("#telphone").prop("value","");
					}
			});
		}
	</script>
</body>
</html>
